#include "file.h"

using namespace std;

File::File(string md5, string name) : md5(md5), name(name) {}

void File::set_file_size(int size) {
	this->size = size;
}

void File::add_fragment(Fragment *fragment) {
	fragments.push_back(fragment);
}

const string &File::get_md5() const {
	return md5;
}

const string &File::get_name() const {
	return name;
}

int File::get_size() const {
	return size;
}

Fragment *File::get_fragment(int id) const {
	if (id <= 0 || id > static_cast<int>(fragments.size())) return 0;
	return fragments[id-1];
}

const std::vector<Fragment *> &File::get_fragments() const {
	return fragments;
}

File::~File() {
	for (size_t i = 0; i <  fragments.size(); i++) {
		delete fragments[i];
	}
}
